@extends('admin.public.header')
@section('title','回复评价')

@section('listcontent')
    <div class="layui-tab-content">
        <form class="layui-form">
            <div class="layui-form layuimini-form">
                <input type="hidden" name="id" value="{{ $info->id ?? '' }}">
                <div class="layui-form-item">
                    <label class="layui-form-label">用户</label> 
                    <div class="layui-input-block">
                        <table class="layui-table">
                            <tr>
                                <td><img style="width:30px;height:30px;" src="{{ $info->avatar }}"><span style="margin-left:15px;">{{ $info->nickname }}</span></td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">商品名称</label> 
                    <div class="layui-input-block">
                        <table class="layui-table">
                            <tr>
                                <td><img style="width:30px;height:30px;" src="{{ $info->goods_pic }}"><span style="margin-left:15px;">{{ $info->goods_name }}</span></td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">评分</label> 
                    <div class="layui-input-block">
                        <div id="score"></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">评价内容</label> 
                    <div class="layui-input-block">
                        <table class="layui-table">
                            <tr>
                                <td>{{ $info->content }}</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label" style="text-align: left;">回复评价</label> 
                    <div class="layui-input-block">
                        <textarea placeholder="请输入回复内容" name="reply_content" class="layui-textarea">{{ $info->reply_content ?? ''}}</textarea>
                    </div>
                </div>
            </div>
            <div class="hr-line"></div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" id="saveBtn" lay-submit lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </form>
    </div>
   
@endsection

@section('listscript')
    <script type="text/javascript">
        layui.use(['layer','form','tree','rate'], function () {
            var layer = layui.layer, form = layui.form,
            $=layui.jquery ,tree = layui.tree ,
            rate = layui.rate;
            var score = '{{ $info->score }}';
            rate.render({
                elem: '#score'
                ,value: score //初始值
            });
            form.on('submit(saveBtn)', function(data){
                var loading = layer.msg('加载中..', {icon: 16,shade: 0.3,time: false});
                $.ajax({
                    url:'/admin/order_comment/reply',
                    type:'post',
                    data:data.field,
                    dataType:"JSON",
                    headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
                    success:function(res){
                        layer.close(loading);  //返回数据关闭loading
                        if(res.code == 0){
                            layer.msg(res.message,{icon: 1},function(){
                                setTimeout('parent.location.reload()',500);
                            });
                            
                        }
                        else{
                            layer.msg(res.message,{icon: 2});
                        }
                    },
                    error:function(e){
                        layer.msg("提交失败",{icon: 2});
                    },
                    
                });
                return false;
            });

        });
    </script>
@endsection

